package com.hundsun.yr.universal.p2p.bean.enums.base;

/**
 * 
 * @author tonglj
 *
 */
public class ClassUtils{


  public static String getShortClassName(Object object, String valueIfNull){
    if (object == null) {
      return valueIfNull;
    }
    return getShortClassName(object.getClass().getName());
  }

  public static String getShortClassName(Class cls) {
    if (cls == null) {
      return "";
    }
    return getShortClassName(cls.getName());
  }

  public static String getShortClassName(String className){
    if (className == null) {
      return "";
    }
    if (className.length() == 0) {
      return "";
    }
    int lastDotIdx = className.lastIndexOf('.');
    int innerIdx = className.indexOf('$', lastDotIdx == -1 ? 0 : lastDotIdx + 1);
    String out = className.substring(lastDotIdx + 1);
    if (innerIdx != -1) {
      out = out.replace('$', '.');
    }
    return out;
  }

  
}